<?php

class Social_Group extends Social_Base
{

    public function init()
    {
        $this->setTableName('groups');
        $this->setPrimaryKey('group_id');
    }

    public function createGroup($sessionKey, $name, $description)
    {
        $this->_valdateName($name);
        $this->_validateDescription($description);
        $user = $this->getUser()->auth($sessionKey);

        $data = array();
        $data['name'] = $name;
        $data['description'] = $description;
        return $this->insert($data);
    }

    // social.group.user
    public function findUserGroups()
    {
    
    }

    private function _validateName($name)
    {
        $this->validate($name, 'name', 'required', null, 'Group name required');
        $this->validate($name, 'name', 'minLenth', 3, 'Group name min length');
        $this->validate($name, 'name', 'maxLenth', 30, 'Group name max length');
    }
}
